// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#include <turbo/flags/flag.h>

#include <pollux/functions/coverage_util.h>
#include <pollux/functions/prestosql/aggregates/register_aggregate_functions.h>
#include <pollux/functions/prestosql/registration/registration_functions.h>
#include <pollux/functions/prestosql/window/window_functions_registration.h>

TURBO_FLAG(bool,all, false, "Generate coverage map for all Presto functions");
TURBO_FLAG(bool,
    most_used,
    false,
    "Generate coverage map for a subset of most-used Presto functions");

using namespace kumo::pollux;

int main(int argc, char** argv) {
  gflags::ParseCommandLineFlags(&argc, &argv, true);

  // Register all simple and vector scalar functions.
  functions::prestosql::registerAllScalarFunctions();

  // Register Presto aggregate functions.
  aggregate::prestosql::registerAllAggregateFunctions();

  // Register Presto window functions.
  window::prestosql::registerAllWindowFunctions();

  if (FLAGS_all) {
    functions::printCoverageMapForAll();
  } else if (FLAGS_most_used) {
    functions::printCoverageMapForMostUsed();
  } else {
    const std::unordered_set<std::string> linkBlockList = {
        "checked_divide",
        "checked_minus",
        "checked_modulus",
        "checked_multiply",
        "checked_negate",
        "checked_plus",
        "in",
        "modulus",
        "not"};
    functions::printPolluxFunctions(linkBlockList);
  }

  return 0;
}
